<template>
    <div class="index">
        <el-collapse>
            <el-collapse-item :title="datas.title" name="1">
                <div v-for="($item, $idx) in datas.items">{{$item.item_name}}</div>
            </el-collapse-item>
            <el-input size="large" placeholder="请输入内容" v-model="itemContent"></el-input>
            <!-- <el-checkbox-group v-model="checkList">
                <el-checkbox label="添加到季报"></el-checkbox>
                <el-checkbox label="添加到年报"></el-checkbox>
            </el-checkbox-group> -->
            <el-checkbox-group v-model="tag">
                <el-checkbox-button>周报</el-checkbox-button>
                <!-- <el-checkbox-button v-for="($item, $idx) in tabs" :label="$item" :key="$idx">{{tabTextMethod($item)}}</el-checkbox-button> -->
            </el-checkbox-group>
            <el-button type="primary" @click="addItemMethod">添加检查项</el-button>
        </el-collapse>
    </div>
</template>
<script>
// import { APIs } from '@utils/apis'
import { mapState } from 'vuex'
import {
    asString,
} from '@utils/dateUtils'

export default {
    data() {
        return {
            itemContent: '',
            tagList: [],
            blockList: [],
            tabs: [1, 2, 3],
            tag: '',
        }
    },

    mounted() {
        this.$nextTick(function() {
            setTimeout(() => {
                this.$store.dispatch('datasAction')
            }, 10)
        })
    },

    computed: {
        ...mapState(['datas'])
    },

    methods: {
        tabTextMethod(idx) {
            if (idx == 1)
                return '周报'
            if (idx == 2)
                return '季报'
            if (idx == 3)
                return '年报'
        },

        addItemMethod() {
            console.log(this.itemContent)
            console.log('tag', this.tag)
            if (this.itemContent && this.itemContent.trim()) {
                this.$store.dispatch('addItemAction', {
                    task_id: this.datas.task_id,
                    content: this.itemContent,
                    // tags: this.tagList,
                    tag: this.tag,
                })
                this.$store.state.datas.items.push({ item_name: this.itemContent })
                this.itemContent = ''
            }
        }
    },
}
</script>
<style lang="less">
</style>